cluster_level = cluster_level %>% filter(dist < 15000)

cluster_plot1 = loess_plot_weighted(x = cluster_level$forcing, y = cluster_level$outcome1, W = cluster_level$opium_legal, ylab = "Pr(Intolerant = Yes)", 
                                    weights = cluster_level$weight, bin_position = cluster_level$bin_position, bin_val = cluster_level$outcome1_weighted_bins)
cluster_plot2 = loess_plot_weighted(x = cluster_level$forcing, y = cluster_level$outcome2, W = cluster_level$opium_legal, ylab = "Pr(Intolerant = Yes)",
                                    weights = cluster_level$weight, bin_position = cluster_level$bin_position, bin_val = cluster_level$outcome2_weighted_bins)
cluster_plot3 = loess_plot_weighted(x = cluster_level$forcing, y = cluster_level$outcome3, W = cluster_level$opium_legal, ylab = "Pr(Intolerant = Yes)",
                                    weights = cluster_level$weight, bin_position = cluster_level$bin_position, bin_val = cluster_level$outcome3_weighted_bins)
cluster_plot4 = loess_plot_weighted(x = cluster_level$forcing, y = cluster_level$outcome4, W = cluster_level$opium_legal, ylab = "Pr(Intolerant = Yes)", 
                                    weights = cluster_level$weight, bin_position = cluster_level$bin_position, bin_val = cluster_level$outcome4_weighted_bins)




ggsave(plot = cluster_plot1, "./_4_outputs/figures/appendix_3a_cluster_plot.pdf", height = 3, width = 4)
ggsave(plot = cluster_plot2, "./_4_outputs/figures/appendix_3b_cluster_plot.pdf", height = 3, width = 4)
ggsave(plot = cluster_plot3, "./_4_outputs/figures/appendix_3c_cluster_plot.pdf", height = 3, width = 4)
ggsave(plot = cluster_plot4, "./_4_outputs/figures/appendix_3d_cluster_plot.pdf", height = 3, width = 4)